package com.sz.common.base.exception;

import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 * Function: bizexception <br>
 * Author: wentao.chang <br>
 * Date: 2016-10-25 14:48:00
 */
public class BizException extends RuntimeException {

    private static final long serialVersionUID = 5813738995813590123L;

    private int errorCode = -1;
    private String msg;
    private Object data;

    public BizException(int errorCode, String msg) {
        this.errorCode = errorCode;
        this.msg = msg;
    }

    public BizException(String msg) {
        this.errorCode = -1;
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "ErrorCode:" + this.getErrorCode()
                + "\r\nData:" + ToStringBuilder.reflectionToString(this.getData() == null ? "" : this.getData())
                + "\r\nMsg:" + this.getMsg();
    }
}
